package mygame.role;

import lombok.Data;
import mygame.role.enums.Career;
import mygame.role.enums.Gender;
import mygame.role.enums.Race;

import java.util.Scanner;

@Data
public class Role {
    private String name;
    private Gender gender;
    private Race race;
    private Career career;
    private int strength;
    private int wisdom;
    private int speed;
    private int mp;
    private int hp;

    public static Role build(){
        System.out.println("你好啊！这里的人都叫我赛丽亚!");
        System.out.println("你叫什么名字呀!");
        Scanner sc = new Scanner(System.in);
        Role myrole = new Role();
        while(sc.hasNextLine()){
            String name = sc.nextLine();
            myrole.setName(name);
            System.out.println("赛丽亚知道啦，接下来选择您的性别：0：男，1：女");
            if(sc.hasNextInt()){
                int sexNum = sc.nextInt();
                if(sexNum==1){
                    myrole.setGender(Gender.WOMAN);
                }else{
                    myrole.setGender(Gender.MAN);
                }
                System.out.println("OK，选择您的职业吧：0：剑士，1：法师");
                if(sc.hasNextInt()){
                    int jobNum = sc.nextInt();
                    if(jobNum==1){
                        myrole.setCareer(Career.CASTER);
                    }else{
                        myrole.setCareer(Career.SABER);
                    }
                }
            }
            //根据角色生成数值，初始总数值为100点，开始分配
            System.out.println("您的角色生成结果如下");
            myrole.setMp(20);
            myrole.setRace(Race.MANKIND);
            if (myrole.getGender().getValue()==1){
                myrole.setSpeed(25);
                myrole.setStrength(15);
            }else if(myrole.getGender().getValue()==0){
                myrole.setSpeed(15);
                myrole.setStrength(25);
            }
            if (myrole.getCareer().getValue()==1){
                //智商高，血少
                myrole.setWisdom(25);
                myrole.setHp(15);
            }else if(myrole.getCareer().getValue()==0){
                //智商低，血量增加
                myrole.setWisdom(15);
                myrole.setHp(25);
            }

            System.out.println(myrole);
            System.out.println("满意这个结果吗，是否需要重新生成：0：否，1：是");
            if(sc.nextInt()==0){
                System.out.println("看来你真的要去冒险了，不用跟我道别，我会一直陪在你身边的！");
                break;
            }else{
                System.out.println("好的，开始重新生成！");
                System.out.println("你叫什么名字呀");
                sc.nextLine();//读一下回车键
                continue;
            }
        }
        return myrole;
    }
}
